$(function () {
    $("#sub").click(function () {
        clearAlert();
        if (checkAccount() & checkPassword()) {
            $.ajax({
                url: "/UserController/User",
                type: "Post",
                contentType:"application/json",
                data:JSON.stringify({"account":$("#account").val(),"password":$("#password").val()}),
                success: function (data) {
                    switch (data) {
                        case true:
                            location.href = "../../jsp/info.jsp";
                            break;
                        case false:
                            $("#apWrongInfo").css("display", "block");
                            break;
                    }
                }
            });
        }

    });
});

function checkAccount() {
    if ($("#account").val() == "") {
        $("#aNullInfo").css("display", "block");
        return false;
    }
    return true;
}

function checkPassword() {
    if ($("#password").val() == "") {
        $("#pNullInfo").css("display", "block");
        return false;
    }
    return true;
}

function clearAlert() {
    $(".alert").css("display", "none");
}